/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.impulserobotics;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Watchdog;

/**
 *
 * @author Sahil Jain
 */
public class BridgeLiftingApparatus {
    
    public Relay spike;
    
    public BridgeLiftingApparatus(){
        spike = new Relay(Constants.BLA_RELAY);
    }
    
    public void down(){
        
        spike.set(Relay.Value.kForward);
        Timer.delay(Constants.LATCH_ROTATION_DELAY);
        spike.set(Relay.Value.kOff);
        Watchdog.getInstance().feed();
    }
    
    public void up(){
        
        spike.set(Relay.Value.kReverse);
        Timer.delay(Constants.LATCH_ROTATION_DELAY);
        spike.set(Relay.Value.kOff);
        Watchdog.getInstance().feed();
    }

    void update(Joystick joy) {
        if(joy.getRawButton(Constants.BLA_DOWN_BUTTON)){
            spike.set(Relay.Value.kForward);
        }else if(joy.getRawButton(Constants.BLA_UP_BUTTON)){
            spike.set(Relay.Value.kReverse);
        }else{
            spike.set(Relay.Value.kOff);
        }
        
    }
}
